require 'migration_helpers'

class CreateStudents < ActiveRecord::Migration
  extend MigrationHelper::ForeignKeys
  
  def self.up
    create_table :students do |t|
      t.column :address_id, :integer
      t.column :school_id, :integer
      t.column :first_name, :string, :null => false
      t.column :last_name, :string, :null => false
      t.column :date_of_birth, :date, :null => false
      t.column :email, :string
      t.column :active, :boolean, :default => true
      t.column :created_at, :datetime
      t.column :updated_at, :datetime
    end
    
    add_foreign_key(:students, :address_id, :addresses)
    add_foreign_key(:students, :school_id, :schools)
  end

  def self.down
    drop_table :students
  end
end
